home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / WCLRTOBO.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  87 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3. #undef wclrtobot
  4.  
  5. #ifndef        NDEBUG
  6. char *rcsid_wclrtobo = "$Header: c:/curses/portable/RCS/wclrtobo.c%v 2.0 1992/11/15 03:28:56 MH Rel $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   wclrtobot()  - erase window
  15.  
  16.   X/Open Description:
  17.        All lines below the cursor in this window are erased.  The current
  18.        line to the right of the cursor, inclusive, is also erased.
  19.  
  20.        NOTE:  clrtobot() is a macro.
  21.  
  22.   PDCurses Description:
  23.        There is no additional PDCurses functionality.
  24.  
  25.   X/Open Return Value:
  26.        The wclrtobot() function returns OK on success and ERR on error.
  27.  
  28.   PDCurses Errors:
  29.        It is an error to call this function with a NULL window pointer.
  30.  
  31.   Portability:
  32.        PDCurses        int wclrtobot( WINDOW* win );
  33.        X/Open Dec '88  int wclrtobot( WINDOW* win );
  34.        BSD Curses      int wclrtobot( WINDOW* win );
  35.        SYS V Curses    int wclrtobot( WINDOW* win );
  36.  
  37. **man-end**********************************************************************/
  38.  
  39. int    wclrtobot(WINDOW *win)
  40. {
  41.        int     y;
  42.        int     minx;
  43. static int     startx;
  44. static chtype  blank;
  45. static chtype* ptr;
  46. static chtype* end;
  47. static chtype* maxx;
  48.  
  49.        if  (win == (WINDOW *)NULL)
  50.                return( ERR );
  51.  
  52.        blank   = win->_blank | win->_attrs;
  53.        startx  = win->_curx;
  54.  
  55.        for (y = win->_cury; y <= win->_bmarg; y++)
  56.        {
  57.                minx    = _NO_CHANGE;
  58.                end     = &win->_y[y][win->_maxx - 1];
  59.                for (ptr = &win->_y[y][startx]; ptr <= end; ptr++)
  60.                {
  61.                        if (*ptr != blank)
  62.                        {
  63.                                maxx = ptr;
  64.                                if (minx == _NO_CHANGE)
  65.                                {
  66.                                        minx = (int) (ptr - win->_y[y]);
  67.                                }
  68.                                *ptr = blank;
  69.                        }
  70.                }
  71.                if (minx != _NO_CHANGE)
  72.                {
  73.                        if ((win->_firstch[y] > minx) ||
  74.                            (win->_firstch[y] == _NO_CHANGE))
  75.                        {
  76.                                win->_firstch[y] = minx;
  77.                                if (win->_lastch[y] < maxx - win->_y[y])
  78.                                {
  79.                                        win->_lastch[y] = (int) (maxx - win->_y[y]);
  80.                                }
  81.                        }
  82.                }
  83.                startx = 0;
  84.        }
  85.        return( OK );
  86. }
  87.